package com.hnkywl.sts.entity.jhgl;

import com.hnkywl.sts.entity.organ.Gys;
import com.hnkywl.sts.entity.organ.Qyjg;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * 说明：采购协议
 * 包:        com.hnkywl.sts.entity.jhgl
 * 类描述:    采购协议
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Where(clause = "deleted!='1'")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("cgxy")
public class Cgxy extends Xy {
    /**
     * 供应商
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GYS_ID")
    private Qyjg gys;

    @OneToMany(mappedBy = "xy",fetch = FetchType.LAZY,cascade = CascadeType.MERGE,targetEntity = Cgwzjh.class)
    private List<Cgwzjh> cgwzjhList;

    @Formula(" (select sum(t.sbsl) from T_BIZ_CGDMX t left join  T_BIZ_CGD a on t.cgd_id=a.id " +
            "left join T_BIZ_HT ht on a.cght_id=ht.id left join T_BIZ_XY xy on ht.xy_id=xy.id " +
            "where t.yjs=1 and xy.id=ID) ")
    private Double yzxl;

    public Qyjg getGys() {
        return gys;
    }

    public void setGys(Qyjg gys) {
        this.gys = gys;
    }

    public List<Cgwzjh> getCgwzjhList() {
        return cgwzjhList;
    }

    public void setCgwzjhList(List<Cgwzjh> cgwzjhList) {
        this.cgwzjhList = cgwzjhList;
    }

    public Double getYzxl() {
        return yzxl;
    }

    public void setYzxl(Double yzxl) {
        this.yzxl = yzxl;
    }
}
